package com.wmjsoft.plugins.security.handler

import com.wmjsoft.plugins.security.config.SecurityConfig
import com.wmjsoft.plugins.security.user.CurrentUser
import net.cloudopt.next.web.Resource
import net.cloudopt.next.web.handler.AutoHandler
import net.cloudopt.next.web.handler.Handler

@AutoHandler
class SecurityHandler:Handler {
    override fun afterCompletion(resource: Resource): Boolean {
        CurrentUser.clearCurrentUser()
        return true
    }

    override fun afterRender(resource: Resource, bodyString: String): Boolean {
        return true
    }

    override fun postHandle(resource: Resource): Boolean {
        return true
    }

    override fun preHandle(resource: Resource): Boolean {
        //校验token,并将上下文存放至线程变量中
        JwtAuth(resource).start()
        return true
    }
}